package core.helpers;

import core.Pilot;

/**
 * Class provides methods for working with HAR data
 */
public class HarHelper
{
	protected static Pilot manager;

	/**
	 * @param p_manager
	 */
	public HarHelper(Pilot p_manager)
	{
		manager = p_manager;
	}

	/**
	 * Updates a HAR ID
	 *
	 * @param p_pathToHarFile Path to HAR file
	 * @param p_harId         HAR ID
	 */
	public void updateID(String p_pathToHarFile, String p_harId)
	{
		// Read a har file
		String harContent = manager.file().read(p_pathToHarFile);
		// Replace har ID
		String harNewContent = harContent.replace(manager.dashboard().getTestName(), p_harId);
		// Clear old file
		manager.file().clear(p_pathToHarFile);
		// Write new content with new ID
		manager.file().update(p_pathToHarFile, harNewContent);
	}

}
